﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ReadExcel
{
    interface IObserver 
    {
        void Update(string state);
    }

    class Observer : IObserver
    {
        ExcelFactory excel;
        string state;

        public Observer(ExcelFactory subject)
        {
            this.excel = subject;
            subject.Notify += Update;
        }

        public void Update(string subjectState)
        {
            state = subjectState;
            Console.WriteLine("Observer : " + state);
        }
    }
    
    class ObserverPattern
    {
        static void Main(string[] args)
        {
            ExcelFactory excel = new ExcelFactory(@"D:/DataSheet.xls");
            Observer Observer = new Observer(excel);
            excel.Go();
            Console.Read();
        }
    }
}
